{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">ID|订单号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ordersn" placeholder="ID|订单号"
                                        value="{:input('get.ordersn')}" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">订单状态</label>
                                <div class="layui-input-inline">
                                    <select name="status" >
                                        <option value="">请选择订单状态</option>
                                        <option value="1" {if !empty(input('get.status')) && input('get.status')==1}selected{/if}>待付款</option>
                                        <option value="2" {if !empty(input('get.status')) && input('get.status')==2}selected{/if}>待配送</option>
                                        <option value="3" {if !empty(input('get.status')) && input('get.status')==3}selected{/if}>配送中</option>
                                        <option value="4" {if !empty(input('get.status')) && input('get.status')==4}selected{/if}>已完成</option>
                                        <option value="5" {if !empty(input('get.status')) && input('get.status')==5}selected{/if}>已取消</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">订单ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">订单编号</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商品信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">收货信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">用户备注</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">计费</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">订单状态</div>
                                </th>
                                                                <th>
                                    <div class="layui-table-cell">物流信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.ordersn|default=''}</div>
                                </td>
                                <td>
                                    {foreach $v.good as $good}
                                    <div id="layer-photos-demo" class="layer-photos-demo">
                                        <img layer-pid="" style="height: 40px;" layer-src="{$good.images[0]|default=''}"
                                            src="{$good.images[0]|default=''}" alt="{$good.title|default=''}">
                                    </div>
                                    <div class="layui-table-cell">{$good.title|default=''}(规格:{$good.name|default=''})
                                        {$good.price|default='0'}元
                                        X{$good.number|default='0'}</div>
                                    {/foreach}
                                </td>
                                <td>
                                    联系人:{$v.name}<br />
                                    联系电话:{$v.mobile}<br />
                                    地址:{$v.province|default=''}{$v.city|default=''}{$v.area|default=''}{$v.getaddress|default=''}{$v.address|default=''}
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.remark|default='无'}</div>
                                </td>
                            
                                <td>
                                    <div class="layui-table-cell">配送费{$v.sendm|default='0'}元</div>
                                    <div class="layui-table-cell">支付:{$v.total|default='0'}积分</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.status_name|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">快递名:{$v.kname|default='无'}</div>
                                    <div class="layui-table-cell">快递单号:{$v.knumber|default='无'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        创建时间:{$v.created|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        支付时间:{$v.paytimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        配送时间:{$v.fwtimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        完成时间:{$v.finishtimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        取消时间:{$v.caceltimes|default='无'}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                    <a title="产品清单" onclick="open_add('产品清单','/system/orderdetail?ordersn={$v.ordersn}')"
                                        href="javascript:;" class="layui-btn layui-btn-sm">
                                        产品清单
                                    </a>
                                    <!-- 取消操作判断 -->
                                    {if $v.status == 1}
                                    <a title="确认取消用户待支付订单吗" onclick="open_status(this,'/system/order_str','{$v.id}',5)" href="javascript:;" class="layui-btn-danger layui-btn layui-btn-sm">
                                        取消订单
                                    </a>
                                    {/if}
                                    {if $v.status == 2 || $v.status == 3}
                                    <a title="订单已支付，取消后订单金额将原路返回" onclick="open_status(this,'/system/order_str','{$v.id}',5)" href="javascript:;" class="layui-btn-danger layui-btn layui-btn-sm">
                                        取消订单
                                    </a>
                                    {/if}
                                    <!-- 配送订单 -->
                                    {if $v.status == 2 || $v.status == 3}
                                    <a title="进行配送订单" onclick="open_alert('填写物流信息','/system/order_str','{$v.id}',3)" href="javascript:;" class="layui-btn layui-btn layui-btn-sm">
                                        发货|更改物流信息
                                    </a>
                                    {/if}
                                    <!-- 完成订单操作 -->
                                    {if $v.status == 2 || $v.status == 3}
                                    <a title="确定完成订单?" onclick="open_status(this,'/system/order_str','{$v.id}',4)" href="javascript:;" class="layui-btn layui-btn-sm">
                                        完成订单
                                    </a>
                                    {/if}
                                    </div>
                                </td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
{include file="public/footer"}
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;
            //监听省份选择
            form.on('select(province)', function (data) {
                if (!data.value) {
                    $('select[name="city"]').html('');
                    $('select[name="area"]').html('');
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 2 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择城市</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.area_code;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="city"]').html(str);
                            $('select[name="area"]').html('');
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听城市选择
            form.on('select(city)', function (data) {
                if (!data.value) {
                    $('select[name="area"]').html('');
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 3 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择区域</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.area_code;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="area"]').html(str);
                            $('select[name="street"]').html('');
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
            //监听区域选择
            form.on('select(area)', function (data) {
                if (!data.value) {
                    $('select[name="street"]').html('');
                    form.render();
                    return false;
                }
                //发异步，把数据提交给php
                $.ajax({
                    type: 'get',
                    url: '/base/getregion',
                    data: { area_code: data.value, level: 4 },
                    success: function (res) {
                        if (res.status == 0) {
                            var str = '<option value="">请选择街道</option>';
                            $.each(res.data, function (i, obj) {
                                str += '<option value="' + obj.id;
                                str += '">' + obj.name;
                                str += '</option>';
                            });
                            $('select[name="street"]').html(str);
                            form.render();
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>